import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Camera, CameraOptions } from '@ionic-native/camera';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  constructor(public navCtrl: NavController, private camera: Camera) {
    // let appid = '10115201';
    // let secretId = 'AKIDSmyEIPSju4PmyyOqBKIArM0Z9f6bqTs9';
    // let secretKey = 'FNivwKivwjOr9WktqeGIF1bzVpx063rT';
    // let userid = '2389961';
  }

  base64Image: String;

  options: CameraOptions = {
    quality: 100,
    destinationType: this.camera.DestinationType.DATA_URL,
    encodingType: this.camera.EncodingType.JPEG,
    mediaType: this.camera.MediaType.PICTURE
  }

  ocrIDCard(event) {
    console.log('Clicked OCR ID Card!')
    console.log(event)
    this.camera.getPicture(this.options).then((imageData) => {
      // imageData is either a base64 encoded string or a file URI
      // If it's base64:
      this.base64Image = 'data:image/jpeg;base64,' + imageData;
     }, (err) => {
      // Handle error
     });
  }

}
